﻿#include "test_temp_obstacles.hpp"
#include "../utils/Vector.hpp"
#include "Finder/NavHelper.h"
#include <string>
#include <iostream>

#include "../json.hpp"
#include <fstream>

test_temp_obstacles test_temp_obstacles::_instance;

void test_temp_obstacles::load()
{
	//auto navfile = Cfg::instance().res_path + "/space/Level04/level.bin.to";
	mesh = NavHelper::GetNavMeshTO((char*)".bin.to");
	if (mesh == nullptr)
	{
		std::cerr << "NavHelper::GetNavMeshTO() fail "  << std::endl;
		return;
	}

	auto obstaclefile = nullptr;
}

void test_temp_obstacles::test()
{
	load();

	FVector3 beginPos(2.69, -2.21, 8.13);
	FVector3 endPos(2.85, -0.69, 6.00);
	

	float* pos = nullptr;
	int count = 0;

	std::cout << "----------------------------------\n";
	std::cout << "1\n";

	pos = NavHelper::FindPathTO(mesh, beginPos.X, beginPos.Y, beginPos.Z, endPos.X, endPos.Y, endPos.Z, &count);

	for (int i = 0; i < count; i++)
	{
		FVector3 tmp(pos[i * 3], pos[i * 3 + 1], pos[i * 3 + 2]);
		tmp = Recast2UnrealPoint(tmp);
		printf("%02f,%02f,%02f\n", tmp.X, tmp.Y, tmp.Z);
	}

}

